package com.abc.recycling.service;

import com.abc.recycling.domain.Message;
import lombok.RequiredArgsConstructor;
import org.springframework.messaging.simp.SimpMessagingTemplate;
import org.springframework.stereotype.Service;

@Service
@RequiredArgsConstructor
public class WebSocketService {

    private final SimpMessagingTemplate messagingTemplate;

    /**
     * 向特定用户发送消息
     */
    public void sendMessageToUser(Long userId, Message message) {
        messagingTemplate.convertAndSend("/topic/user/" + userId, message);
    }

    /**
     * 向所有用户广播消息
     */
    public void broadcastMessage(Message message) {
        messagingTemplate.convertAndSend("/topic/broadcast", message);
    }

    public void sendMessage(Long userId, String message) {
        // Implementation needed
    }

    public void sendSystemMessage(String message) {
        // Implementation needed
    }

    public void broadcastMessage(String message) {
        // Implementation needed
    }
} 